Headshot Only with Sniper (disable other hitbox areas)
Is it possible when a player has a specific weapon to disable all hitboxes other than 0 1 and 2 (head, helmet and neck)? I want all weapons other than a sniper to be able to shoot anywhere and do damage, but when the player has a sniper - only headshots would do damage to the player. I've searched around and found one post on TMT that didn't go anywhere productive.. Any ideas here?
Last edited by [cB]SplatterGuts; April 12th, 2015 at 11:09 PM.
Do you want the player who is holding the sniper to be headshot only,
OR
Anyone who gets SHOT by the sniper, regardless of what weapon they are holding, is headshot.
Thanks!! This works, but it works on all of the weapons, not just the sniper rifle.
I tried this under the spawned event to make it only work for the springfield:
spawnedlocal.attacker local.damage local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.player:local.player takealllocal.player give models/weapons/springfield.tik
local.player give models/weapons/colt45.tik
local.player useweaponclass rifle
/// Makes sure both attacker and victim are playersif(local.player.classname =="Player"&&local.attacker.classname =="Player"){/// Loops through inventoryfor(local.i=0;local.i <local.attacker.inventory.size;local.i++){/// stores weaponlocal.weapon =local.attacker.inventory[local.i]// Until finds weaponsif(local.weapon.model =="models/weapons/springfield.tik"){for(local.i =0;local.i <18;local.i++){local.player damagemultlocal.i 0.0}local.player damagemult010.0// Headlocal.player damagemult110.0// Helmetlocal.player damagemult210.0// Neck}}}}
But it doesn't do anything different from the code you had posted.
Note: I had to use the hit locations posted by PE in another post for them to work correctly
Spoiler: [QUOTE=Purple Elephant1au;20547
I am pretty sure those locations are incorrect
Theres been 2 different sets of locations running around , and when i tested both of them , i found these ones to be accurate
Code:
-1 - General - ie:bash, rocket in the kisser, blown away, played catch, etc..
0 - Head
1 - Helmet
2 - Neck
3 - Upper Torso
4 - Middle Torso
5 - Lower Torso
6 - Pelvis
7 - Upper Right Arm
8 - Upper Left Arm
9 - Upper Right Leg
10 - Upper Left Leg
11 - Lower Right Arm
12 - Lower Left Arm
13 - Lower Right Leg
14 - Lower Left Leg
15 - Right Hand
16 - Left Hand
17 - Right Foot
18 - Left Foot
why is that ?
I have seen both but only ever seen this one to be the working one ?
Does each one apply to a different entity or ? [/QUOTE]
]
@PE -- The player who has a sniper in their hand, I want them to only be able to kill others by shooting them in the head, regardless of the other players weapon.
Last edited by [cB]SplatterGuts; April 12th, 2015 at 11:09 PM.
@PE -- The player who has a sniper in their hand, I want them to only be able to kill others by shooting them in the head, regardless of the other players weapon.
Thats where it can get tricky, because the damagemult applies to the player, not to how the weapon reacts.
So want you want is to apply the headshot only to players who get shot by the sniper, or remove damage to other locations if its the sniper shooting and only damage the player when its a headshot.
A possible way to do this would be something like
On spawn, set all other locations damagemult to 0.01 or something smallish but enough to cause like 1 damage so event is triggered, leave headshots as stock.
Then on damage event, check which weapon was used to inflict the damage, if it is not the sniper and not a headshot, then applie the normal amount of damage to the player which they should of got if you didnt negate the damagemult.
Does that make sense.
Since you cant stop damage in its tracks on the event, but you could stop it with damagemult and just apply it later when you want to, only with certain conditions.
So basically the process would be
player gets shot(damaged since other body shots are not 1 hit kills)
check if inflictors weapon is sniper >> if yes then dont apply any damage
>> if no, then inflict the correct amount of damage that would of normally been applied to the player
EDIT::
Something like this,
Note this is untested and might have spelling mistakes etc but its the general idea
First on spawn event, set all damagemult to 0.1 or something small, but enough to trigger the damage event, on all locations BESIDES the headshot ones, ie 0,1,2
then try this has the damage event
damagelocal.target local.inflictor local.damage local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.entity://Local.player will be the player who got damaged, idk if its target or entitylocal.player =local.entity
///local.player = local.targetif(local.player.classname =="Player"&&local.inflictor.classname =="Player"){/// If locations are head, helmet or neck, end because we didnt touch these damagemult locationsif(local.location ==0||local.location ==1||local.location ==2)end// Gets current gun of the inflictorlocal.gun =local.inflictor getactiveweap0/// If gun is a sniper end, because we want no damage to them ( you can always had the 1 hp back that is needed to be taken to trigger the event )if(local.gun.model =="models/weapons/springfield.tik"||local.gun.model =="models/weapons/kar98sniper.tik")end////// find correct damagemult ///////load array from threadlocal.damagemult_array =waitthread get_damagemult_array
for(local.i =1;local.i <=local.damagemult_array.size;local.i++){if(local.location ==local.damagemult_array[local.i][1]){local.normal_damagemult =local.damagemult_array[local.i][2]break;}}// i think its how you get the damage, Note if it cant be done this way then you will have to make an array with the damage per weapon, it might be Set varible only not read..../// Check above array and looplocal.normal_bulletdamage =local.gun.dmbulletdamage
// Calculate correct damagelocal.normal_damage =local.normal_bulletdamage *local.normal_damagemult
///damage( Entity attacker, Integer damage, Entity inflictor, Vector position, Vector direction, Vector normal, Integer knockback, Integer damageflags, Integer meansofdeath, Integer location )//apply damage// Target /// Inflictor /// Damagelocal.player damagelocal.inflictor local.normal_damage local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location
}endget_damagemult_array:// Store stock damagemult values in array by locationlocal.damagemult_array =makeArray//Location // Value"-1""1.00""0""2.00""1""2.00""2""2.00""3""1.00""4""0.95""5""0.90""6""0.85""7""0.80""8""0.80""9""0.80""10""0.80""11""0.60""12""0.60""13""0.60""14""0.60""15""0.50""16""0.50""17""0.50""18""0.50"endArrayendlocal.damagemult_array
OR
As you stated in chat, you could just focus on snipers lol
so start by setting both snipers dmbulletdamage to 1 or something small
Then in damage event, check if a sniper weapon shot in the head, apply more damage to kill the player, thus if the weapon was not sniper, or not a headshot, it wont be touched
damagelocal.target local.inflictor local.damage local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.entity://Local.player will be the player who got damaged, idk if its target or entitylocal.player =local.entity
///local.player = local.targetif(local.player.classname =="Player"&&local.inflictor.classname =="Player"){/// If locations are head, helmet or neckif(local.location ==0||local.location ==1||local.location ==2){// Gets current gun of the inflictorlocal.gun =local.inflictor getactiveweap0/// If gun is a sniper apply 200 damage to kill themif(local.gun.model =="models/weapons/springfield.tik"||local.gun.model =="models/weapons/kar98sniper.tik"){//apply damage// Target /// Inflictor /// Damagelocal.player damagelocal.inflictor 200local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location
}}}end
Last edited by Purple Elephant1au; April 13th, 2015 at 04:53 AM.
You could also try to add <damage> health, because as far as I remember, damage event is executed before the rest of the damage logic, so health+damage-damage=health if you would want to omit some damage.
damagelocal.target local.inflictor local.damage local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.entity://Local.player will be the player who got damaged, idk if its target or entitylocal.player =local.entity
///local.player = local.targetif(local.player.classname =="Player"&&local.inflictor.classname =="Player"){/// If locations are head, helmet or neckif(local.location ==0||local.location ==1||local.location ==2){// Gets current gun of the inflictorlocal.gun =local.inflictor getactiveweap0/// If gun is a sniper apply 200 damage to kill themif(local.gun.model =="models/weapons/springfield.tik"){//apply damage// Target /// Inflictor /// Damagelocal.player damagelocal.inflictor 200local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location
}}}end
This works perfectly. And I can set the dm weapon settings for this gametype (like how ckr is set in you weapon limiter mod basically) so that this can be used without messing up too much stuff on a server ;P You rock!